using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using jaam_butters.Agents;


namespace jaam_butters.Ground
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class EvilGround : DrawableGameComponent
    {
        public static Texture2D sprite { get; private set; }
        SpriteBatch spriteBatch;
        Vector2 Position { get; set; }
        Game game;
        BoundingBoxCollider thorn;
        Jaam character;

        public EvilGround(Game g, Vector2 position,Jaam jaam,SpriteBatch sb)
            : base(g)
        {
            Position = position;
            spriteBatch = sb;
            character = jaam;
            game = g;
            LoadContent();
        }

        protected override void LoadContent()
        {
            sprite = game.Content.Load<Texture2D>("lava");
            thorn = new BoundingBoxCollider(sprite, Position);
            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            thorn.Draw(spriteBatch);
            //base.Draw(gameTime);
        }


        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            CheckCharacterEvilGroundCollision();
            //base.Update(gameTime);
        }

        private void CheckCharacterEvilGroundCollision()
        {
            if (thorn.BoundingBox.Contains((int)character.Position.X, (int)character.Position.Y))
            {
                character.ResetCommandReader();
                character.myController.deathFrames = 120;
            }
                
        }
    }
}
